#include "source.h"
#include "core1.h"

void core1_interrupt_handler() {
  while (multicore_fifo_rvalid()) {
    uint32_t raw = multicore_fifo_pop_blocking();
    uint32_t sec = raw & 63;
    uint32_t min = (raw >> 6) & 63;
    uint32_t hr = (raw >> 12) & 31;
    printf("Recovered time %d:%d:%d\n", hr, min, sec);  
  }
  multicore_fifo_clear_irq();
}

void core1_entry() {
  multicore_fifo_clear_irq();
  irq_set_exclusive_handler(SIO_IRQ_PROC1, core1_interrupt_handler);
  irq_set_enabled(SIO_IRQ_PROC1, true);

  while (true) {
    sleep_ms(100);
  }
}
